﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MobileMake.Models
{
    public class EntityDataProvider : IDataProvider
    {
        private DBEntities _entities = new DBEntities();

        #region IDataProvider Members

        public Portal AddPortal(Portal portalToAdd)
        {
            _entities.AddToPortalSet(portalToAdd);
            _entities.SaveChanges();
            return portalToAdd;
        }

        public void DeletePortal(Portal portalToDelete)
        {
            var originalPortal = GetPortal(portalToDelete.PortalID);
            _entities.DeleteObject(originalPortal);
            _entities.SaveChanges();
        }

        public Portal UpdatePortal(Portal portalToUpdate)
        {
            var originalPortal = GetPortal(portalToUpdate.PortalID);
            _entities.ApplyPropertyChanges(originalPortal.EntityKey.EntitySetName, portalToUpdate);
            _entities.SaveChanges();
            return portalToUpdate;
        }

        public Portal GetPortal(int portalId)
        {
            return (from p in _entities.PortalSet 
                    where p.PortalID == portalId
                    select p).FirstOrDefault(); 
        }

        public Portal GetPortalByTab(int tabId)
        {
            throw new NotImplementedException();
        }

        public List<Portal> GetPortals()
        {
            return _entities.PortalSet.ToList();
        }

        public Tab AddTab(Tab tabToAdd)
        {
            throw new NotImplementedException();
        }

        public Tab UpdateTab(Tab tabToUpdate)
        {
            throw new NotImplementedException();
        }

        public void DeleteTab(Tab tabToDelete)
        {
            throw new NotImplementedException();
        }

        public List<Tab> GetTabs(int portalId)
        {
            throw new NotImplementedException();
        }

        public List<Tab> GetAllTabs()
        {
            throw new NotImplementedException();
        }

        public Tab GetTab(int tabId)
        {
            throw new NotImplementedException();
        }

        public List<TabModule> GetPortalTabModules(int portalId, int tabId)
        {
            throw new NotImplementedException();
        }

        public List<TabModule> GetTabModules(int tabId)
        {
            throw new NotImplementedException();
        }

        public List<string> GetTabPanes(int tabId)
        {
            throw new NotImplementedException();
        }

        public List<TabCondition> GetTabConditions(int tabId)
        {
            throw new NotImplementedException();
        }

        public TabCondition GetTabCondition(int moduleId, int tabConditionId)
        {
            throw new NotImplementedException();
        }

        public TabCondition AddTabCondition(TabCondition tabConditionToAdd)
        {
            throw new NotImplementedException();
        }

        public TabCondition UpdateTabCondition(TabCondition tabConditionToUpdate)
        {
            throw new NotImplementedException();
        }

        public void DeleteTabCondition(TabCondition tabConditionToDelete)
        {
            throw new NotImplementedException();
        }

        public List<Module> GetAllModules()
        {
            throw new NotImplementedException();
        }

        public List<Module> GetModules(int portalId)
        {
            throw new NotImplementedException();
        }

        public List<TabModule> GetAllTabsModules(int portalId)
        {
            throw new NotImplementedException();
        }

        public Module GetModule(int moduleId, int tabId)
        {
            throw new NotImplementedException();
        }

        public Module AddModule(Module moduleToAdd)
        {
            throw new NotImplementedException();
        }

        public Module UpdateModule(Module moduleToUpdate)
        {
            throw new NotImplementedException();
        }

        public void DeleteModule(Module moduleToDelete)
        {
            throw new NotImplementedException();
        }

        public List<TabModule> GetTabModuleOrder(int tabId, string paneName)
        {
            throw new NotImplementedException();
        }

        public void UpdateModuleOrder(int tabId, int moduleId, int moduleOrder, string paneName)
        {
            throw new NotImplementedException();
        }

        public TabModule AddTabModule(TabModule tabModuleToAdd)
        {
            throw new NotImplementedException();
        }

        public TabModule UpdateTabModule(TabModule tabModuleToUpdate)
        {
            throw new NotImplementedException();
        }

        public void DeleteTabModule(TabModule tabModuleToDelete)
        {
            throw new NotImplementedException();
        }

        public List<ModuleSetting> GetModuleSettings(int moduleId)
        {
            throw new NotImplementedException();
        }

        public ModuleSetting GetModuleSetting(int moduleId, string settingName)
        {
            throw new NotImplementedException();
        }

        public ModuleSetting AddModuleSetting(ModuleSetting moduleSettingToAdd)
        {
            throw new NotImplementedException();
        }

        public ModuleSetting UpdateModuleSetting(ModuleSetting moduleSettingToUpdate)
        {
            throw new NotImplementedException();
        }

        public void DeleteModuleSetting(ModuleSetting moduleSettingToDelete)
        {
            throw new NotImplementedException();
        }

        public List<TabModuleCondition> GetTabModuleConditions(int moduleId)
        {
            throw new NotImplementedException();
        }

        public TabModuleCondition GetTabModuleCondition(int moduleId, int tabModuleConditionId)
        {
            throw new NotImplementedException();
        }

        public TabModuleCondition AddTabModuleCondition(TabModuleCondition tabModuleConditionToAdd)
        {
            throw new NotImplementedException();
        }

        public TabModuleCondition UpdateTabModuleCondition(TabModuleCondition tabModuleConditionToUpdate)
        {
            throw new NotImplementedException();
        }

        public void DeleteTabModuleCondition(TabModuleCondition tabModuleConditionToDelete)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}
